<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<title>Test that blob: URLs fail registerProtocolHandler checks</title>
<body>

<script>
setup({single_test: true});

const winSrc =
`<html>
<head>
<script>
try {
  navigator.registerProtocolHandler('web+test',
                                    location.href + '?%s',
                                    'Test handler');
  window.opener.postMessage('rph succeeded', '*');
} catch (e) {
  window.opener.postMessage('rph failed: ' + e.message, '*');
}
<\/script>
<\/head>
<body>
Test page
<\/body>
<\/html>
`

window.addEventListener('message', (msg) => {
  assert_equals(msg.data,
                'rph failed: Failed to execute \'registerProtocolHandler\' on \'Navigator\': The scheme of the url provided must be HTTP(S).',
                'registerProtocolHandler should have failed');
  done();
});

const data = new Blob([winSrc], {type: 'text/html'});
const objectURL = window.URL.createObjectURL(data);
window.open(objectURL, '_blank');
</script>
</body>
